Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • spmaps | remove certain parts of a polygon

    Hi. I don't know whether I am right here with my question, but I have the following problem:

    I want to use spmaps to plot the European Union with both country borders and regional borders (NUTS1 level).

    I know the code for doing so. However, the shapefile at country-level (https://ec.europa.eu/eurostat/cache/...16-01m.shp.zip) contains also the EU's overseas territories and islands (Acores, Guyana etc.). Now when I plot this shapefile in its enirety, the "core" Europe becomes very small (a bit like the Alaska-Hawaii-location problem in US maps).

    It is easy to exclude these overseas regions at the disaggregated NUTS1 level, there I can easily identify the overseas territories by there NUTS codes and use
    Code:
    spmap datavar if region != "overseas" using shapefile, id(_ID)
    This is however not possible on the country level, so I cannot code sth. like
    Code:
    spmap datavar if region != "overseas" using shapefile, id(_ID) polygon(data(countrylevel_shp) select(keep if region != "overseas"))
    I tried erasing some observations in the country-level shapefile by merging it on _X and _Y with the region-level shapefile to identify and flag those parts of the polygon that I don't want to map. It didn't work out -- there was no match.

    Do you know how to solve this problem? I really don't know what to do.

    Thanks for any advice!

  • #2
    After some manual manipulation of the country level shapefile and the regional database file:
    Code:
    cd "C:\Users\Scott\Desktop\temp1"
    spshape2dta  nuts_rg_01m_2016_3035_levl_0, replace
    use  nuts_rg_01m_2016_3035_levl_0_shp,clear
    drop if _X <  2100000
    drop if _Y < 0
    save,replace
    
    spshape2dta  nuts_rg_01m_2016_3035_levl_1, replace
    use nuts_rg_01m_2016_3035_levl_1.dta,clear
    drop if _CX < 2000000
    save, replace
    
    spmap using  nuts_rg_01m_2016_3035_levl_1_shp, id(_ID) /// 
     ocolor(blue ) os(vthin) ///
     polygon(data(nuts_rg_01m_2016_3035_levl_0_shp) osize(vthin))
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	255.8 KB
ID:	1530993

    Comment


    • #3
      Wow thank you Scott! That works pretty well.

      Comment

      Working...
      X